<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class SysSettingItem extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
        $table = $this->table('sys_setting_item', [
            'collation' => 'utf8mb4_general_ci'
        ]);
        $table->addColumn('setting_id', 'integer', [
            'limit' => 1, 'null' => false, 'default' => '0', 'signed' => false, 'comment' => '所属配置分类'
        ]);
        $table->addColumn('name', 'string', [
            'limit' => 255, 'null' => false, 'default' => '', 'comment' => '配置名称'
        ]);
        $table->addColumn('key', 'string', [
            'limit' => 255, 'null' => false, 'default' => '', 'comment' => '配置标识'
        ]);
        $table->addColumn('value', 'text', [
            'comment' => '配置值'
        ]);
        $table->addColumn('type', 'string', [
            'limit' => 255, 'null' => false, 'default' => 'input:text', 'comment' => '类型 input:text input:number textarea radio checkbox select'
        ]);
        $table->addColumn('options', 'json', [
            'comment' => '备选项'
        ]);
        $table->addColumn('rules', 'json', [
            'comment' => '规则'
        ]);
        $table->addColumn('placeholder', 'string', [
            'limit' => 255, 'null' => false, 'default' => ''
        ]);
        $table->addColumn('create_time', 'datetime', [
            'comment' => '创建时间'
        ]);
        $table->addColumn('delete_time', 'datetime', [
            'comment' => '删除时间'
        ]);
        $table->create();
    }
}
